package com.dp.system.client;

import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

@Component
public class MqttRunner implements CommandLineRunner {
    private final AliyunMqttClient aliyunMqttClient;

    public MqttRunner(AliyunMqttClient aliyunMqttClient) {
        this.aliyunMqttClient = aliyunMqttClient;
    }

    @Override
    public void run(String... args) {
        aliyunMqttClient.connect();
        // 连接成功后可发布消息
        aliyunMqttClient.publishMessage("你的Topic", "测试消息");
    }
}